package cn.nxcoder.jmw.core;


/**
 * 返回json基类
 */
public class JsonResult<T> {

    /**
     * 异常码
     */
    private String code = "0";

    /**
     * 异常信息
     */
    private String msg = "操作成功";

    private T data;

    public JsonResult() {
    }

    public JsonResult(BusinessErrorException ex) {
        this.code = ex.getCode();
        this.msg = ex.getMessage();
    }

    public JsonResult(BusinessMsgEnum msg) {
        this.code = msg.code();
        this.msg = msg.msg();
    }

    public JsonResult(T data) {
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
